<?php if (isset($this->paginator)):?>
    <?php $userApi = Engine_Api::_()->user(); $qApi = Engine_Api::_()->poll();?>
    <?php if (!$this->isAjax):?>
    <ul id="iVoters" class="iVoters">
    <?php endif;?>
    <?php foreach ($this->paginator as $item):?>
        <?php $user = $userApi->getUser($item->user_id);?>
        <li>
            <div class="user_info">
            <?php echo $this->htmlLink($user->getHref(), $this->itemPhoto($user));?>
            <?php echo $this->htmlLink($user->getHref(), $user->getTitle(), array('class' => 'user_info_title'));?>
            </div>
            <div class="user_action">
            <?php if ($user->getIdentity() != $this->viewer->getIdentity()): ?>
                <?php $f = $qApi->isFriend($this->viewer, $user);?>
                <?php if ($f == 0):?>
                <a href="<?php echo $this->url(array('controller' => 'friends', 'action' => 'add', 'user_id' => $user->getIdentity()), 'user_extended', true);?>" class="fb_add fb_btn smoothbox"><i class="add_friend"></i><?php echo $this->translate('Add Friend');?></a>
                <?php elseif ($f == 2):?>
                <span class="iwaiting_membership_approval"><?php echo $this->translate('Waiting Approval');?></span>
                <?php endif;?>
            <?php endif; ?>                
            </div>
        </li>
    <?php endforeach;?>
    <?php if (!$this->isAjax):?>
    </ul>    
    <?php endif;?>
    <?php
    $tc = $this->paginator->getTotalItemCount();
    $ipp = $this->paginator->getItemCountPerPage();
    $ci = $this->paginator->getCurrentItemCount();
    $cp = $this->paginator->getCurrentPageNumber();
    ?> 
    <?php if ((($cp - 1) * $ipp) + $ci < $tc):?>    
        <?php if (!$this->isAjax):?>
        <a id="show_more" class="show_more" onclick="iShowMoreVoters(<?php echo $cp;?>)">
            <span class="show_more_text"><?php echo $this->translate('See more');?></span>
        </a>
        <?php else:?>
        <script type="text/javascript">iCurrentPage = <?php echo $cp;?>;</script>        
        <?php endif;?>
    <?php else: ?>
    <script type="text/javascript">if ($('show_more')) $('show_more').destroy();</script>
    <?php endif;?>
    <?php if (!$this->isAjax):?>
    <script type="text/javascript">
    window.addEvent('domready', function(){ 
        parent.document.id('TB_closeAjaxWindow').setStyle('display', 'block');
        parent.document.id('TB_closeAjaxWindow').set('html', '<div class="tb_close" onclick="parent.document.id(\'TB_closeAjaxWindow\').setStyle(\'display\', \'none\');Smoothbox.close();"><i class="iClose"></i></div>');
    });
    var iCurrentPage = <?php echo $cp;?>;
    function iShowMoreVoters() {
        $request = new Request.HTML({
            url : en4.core.baseUrl + 'poll/poll/voters',
            format : 'html',
            data : {
                option : <?php echo $this->option->getIdentity();?>,
                page : (iCurrentPage + 1),
                isAjax : 1
            },
            onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript) {
                if (responseHTML) {
                    $('iVoters').set('html', $('iVoters').get('html') + responseHTML);
                }    
                setTimeout(responseJavaScript, 1000);
            }
        }).post();
    }
    </script>    
    <a href="javascript:void(0)" style="float: right; margin: 5px 10px 5px 5px;" onclick="parent.Smoothbox.close();" class="fb_confirm fb_btn"><?php echo $this->translate('Close');?></a>
    <?php endif;?>
<?php endif;?>